﻿var DelIds = "";
var UpdateIds = "";
var listPageCount = 1;
var DelFlag = false;
var UpFlag = false;
function InitJsData(strDelIds,strUpdateIds ) {
    DelIds = strDelIds;
    UpdateIds = strUpdateIds;
}
function showProcess(blnDEl, blnUp) {
   DelFlag = blnDEl;
   UpFlag = blnUp;
   if (DelFlag)
       DelPub();
   if (UpFlag)
       UpPub();
}
//删除
function DelPub() {
    $("#spaceusedAdDel").progressBar(1);
    ExtraCount = DelIds.toString().replace(" ", "").split(',').length;
    ExtraArray = DelIds.toString().replace(" ", "").split(',');
    ExtraPostCount = ExtraCount; //回传次数
    tempExtraIndex = 0; //当前进度
    for (tempPost = 0; tempPost < ExtraPostCount; tempPost++) {
        tempExtras = ExtraArray[tempPost];
        for (i = 1; i <= listPageCount; i++) {
            $.ajax({
                cache:false,
                url: "advertisement_update.aspx?AjaxPostBack=true&type=Del" + "&index=" + i + "&countNum=1" + "&ids=" + tempExtras,
                success: function(msg) {
                    tempExtraIndex += 1;
                    $("#spaceusedAdDel").progressBar(Math.floor(100 * tempExtraIndex / parseInt(ExtraPostCount * listPageCount)));
                },
                error: function(xmlHttpRequest, error) {
                    tempExtraIndex += 1;
                    $("#spaceusedAdDel").progressBar(Math.floor(100 * tempExtraIndex / parseInt(ExtraPostCount * listPageCount)));
                }
            });
        }
    }
}
//更新
function UpPub() {
    $("#spaceusedAdUpdate").progressBar(1);
    ExtraCount = UpdateIds.toString().replace(" ", "").split(',').length;
    ExtraArray = UpdateIds.toString().replace(" ", "").split(',');
    ExtraPostCount = ExtraCount; //回传次数
    tempExtraIndex = 0; //当前进度
    for (tempPost = 0; tempPost < ExtraPostCount; tempPost++) {
        tempExtras = ExtraArray[tempPost];
        for (i = 1; i <= listPageCount; i++) {
            $.ajax({
                cache: false,
                url: "advertisement_update.aspx?AjaxPostBack=true&type=Up" + "&index=" + i + "&countNum=1" + "&ids=" + tempExtras,
                success: function(msg) {
                    tempExtraIndex += 1;
                    $("#spaceusedAdUpdate").progressBar(Math.floor(100 * tempExtraIndex / parseInt(ExtraPostCount * listPageCount)));
                },
                error: function(xmlHttpRequest, error) {
                    tempExtraIndex += 1;
                    $("#spaceusedAdUpdate").progressBar(Math.floor(100 * tempExtraIndex / parseInt(ExtraPostCount * listPageCount)));
                }
            });
        }
    }
}
function  InitlistPageCount(intlistPageCount)
{
    listPageCount = intlistPageCount;
}